feat: Add generated Open Graph images for docs pages - #769
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every docs page gets a social card matching the serverpod.dev feature-page design when its link is shared. Pages with an explicit
imagein frontmatter keep it; pages with an empty title (the CLI command wrappers) get no card rather than a blank one.Screenshots
Creating endpoint methods

Database backups (Cloud)

Design
The layout reproduces the feature cards from pixel measurements of the real og:images at serverpod.dev: Inter Black 64px titles and Inter Regular 38.5px descriptions at the measured baselines, the sampled background gradient and glow, and the same icon footprint and 80px icon-to-text gap. Text is shaped with fontkit so Inter's GPOS kerning applies, which a stripe-composite comparison against the reference card confirms at antialiasing precision. The fonts are vendored from the pinned Inter 4.1 release with their OFL license.
Two decisions from design review are intentional:
description.How it works
plugins/open-graph-images) renders one 1200x630 JPEG per unique card at build time. Card identity is a content hash of title, description, and a render fingerprint covering the renderer source, logo, icon, fonts, and library versions. The swizzledDocItem/Metadatacomputes the same ID client-side, so no manifest is needed and identical cards dedupe across all doc versions: 350 cards cover 1,599 pages (about 30 MB)..docusauruswith atomic writes and orphan cleanup, and the webpack DefinePlugin value is version-keyed so persistent caches can never serve stale IDs.Verification
util/verify_open_graph_images.jsgates both CI and deploy after each build: it parses every page's head with cheerio and checks that every og:image is a valid URL, every card reference resolves to an emitted, fully decodable 1200x630 JPEG, every eligible docs page carries an og:image, and no card is orphaned. The deploy workflow also runs the unit tests before building.Prior art
The closest existing solution, @acid-info/docusaurus-og (Satori-based, alpha, pinned to Docusaurus 3.8.1), cannot reproduce the pixel-matched design, GPOS kerning, or the manifest-free architecture, so a small local plugin was built instead.
The second commit separately removes leftover Docusaurus template comments from
docusaurus.config.js.